module sys_array_3_3 #(
    parameter DW = 8
) (
    input wire clk,
    input wire rst,
    input wire data_rst,
    input wire ini,
    input wire data_en,
    input wire [DW-1:0] act0,
    input wire [DW-1:0] act1,
    input wire [DW-1:0] act2,
    input wire [DW-1:0] wei0,
    input wire [DW-1:0] wei1,
    input wire [DW-1:0] wei2,
    output wire [DW*2-1:0] sum0,
    output wire [DW*2-1:0] sum1,
    output wire [DW*2-1:0] sum2
);

wire [DW-1:0] next_weight01 [2:0];
wire [DW-1:0] next_weight12 [2:0];
wire [DW-1:0] next_activation01 [2:0];
wire [DW-1:0] next_activation12 [2:0];
wire [DW*2-1:0] next_sum01 [2:0];
wire [DW*2-1:0] next_sum12 [2:0];

//第一行
    PE #(
        .DW 		( DW 		))
    u_PE00(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( act0 		),
        .weight_in     		( wei0     		),
        .pre_sum_in    		( {2*DW{1'b0}}    		),
        .next_weight   		( next_weight01[0]   		),
        .next_activation    ( next_activation01[0]  ),
        .next_sum      		( next_sum01[0]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE01(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( act1 		),
        .weight_in     		( wei1     		),
        .pre_sum_in    		( next_sum01[0]    		),
        .next_weight   		( next_weight01[1]   		),
        .next_activation    ( next_activation01[1]  ),
        .next_sum      		( next_sum12[0]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE02(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( act2 		),
        .weight_in     		( wei2     		),
        .pre_sum_in    		( next_sum12[0]    		),
        .next_weight   		( next_weight01[2]   		),
        .next_activation	( next_activation01[2]   		),
        .next_sum      		( sum0      		)
    );

//第二行
    PE #(
        .DW 		( DW 		))
    u_PE10(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation01[0] 		),
        .weight_in     		( next_weight01[0]     		),
        .pre_sum_in    		( {2*DW{1'b0}}    		),
        .next_weight   		( next_weight12[0]   		),
        .next_activation    ( next_activation12[0]  ),
        .next_sum      		( next_sum01[1]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE11(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation01[1] 		),
        .weight_in     		( next_weight01[1]     		),
        .pre_sum_in    		( next_sum01[1]    		),
        .next_weight   		( next_weight12[1]   		),
        .next_activation    ( next_activation12[1]  ),
        .next_sum      		( next_sum12[1]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE12(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation01[2] 		),
        .weight_in     		( next_weight01[2]     		),
        .pre_sum_in    		( next_sum12[1]    		),
        .next_weight   		( next_weight12[2]   		),
        .next_activation	( next_activation12[2]   		),
        .next_sum      		( sum1      		)
    );

//第三行
    PE #(
        .DW 		( DW 		))
    u_PE20(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation12[0] 		),
        .weight_in     		( next_weight12[0]     		),
        .pre_sum_in    		( {2*DW{1'b0}}    		),
        .next_weight   		(    		),
        .next_activation    (   ),
        .next_sum      		( next_sum01[2]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE21(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation12[1] 		),
        .weight_in     		( next_weight12[1]     		),
        .pre_sum_in    		( next_sum01[2]    		),
        .next_weight   		(    		),
        .next_activation    (   ),
        .next_sum      		( next_sum12[2]      		)
    );

    PE #(
        .DW 		( DW 		))
    u_PE22(
        .clk           		( clk           		),
        .rst           		( rst           		),
        .data_rst      		( data_rst      		),
        .ini           		( ini           		),
        .data_en       		( data_en       		),
        .activation_in 		( next_activation12[2] 		),
        .weight_in     		( next_weight12[2]     		),
        .pre_sum_in    		( next_sum12[2]    		),
        .next_weight   		(    		),
        .next_activation	(    		),
        .next_sum      		( sum2      		)
    );

endmodule